#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016-2018, Niklas Hauser
# Copyright (c) 2017, Fabian Greif
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------


def init(module):
    module.name = ":debug"
    module.description = FileReader("module.md")


def prepare(module, options):
    target = options[":target"].identifier
    if target["platform"] == "hosted":
        # FIXME: Move logger/hosted/default_style.cpp into platform
        module.depends(":driver:terminal")

    module.depends(
        ":architecture",
        ":io",
        ":utils")
    return True


def build(env):
    env.outbasepath = "modm/src/modm/debug"

    ignore_patterns = ["debug.hpp"]
    target = env[":target"].identifier
    if target["platform"] != "hosted":
        ignore_patterns.append("*logger/hosted/*")

    env.copy(".", ignore=env.ignore_paths(*ignore_patterns))

    env.outbasepath = "modm/src/modm"
    env.copy("debug.hpp")

